package com.qidian.mes.qc.service.impl;


import com.qidian.mes.pojo.TemplateProduct;
import com.qidian.mes.qc.mapper.TemplateProductMapper;
import com.qidian.mes.qc.service.TemplateProductService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class TemplateProductServiceImpl implements TemplateProductService {
@Autowired
private TemplateProductMapper templateProductMapper;
    @Override
    public MESResult queryById(Long templateId) {
        List<TemplateProduct> list = templateProductMapper.list(templateId);
        return MESResult.ok(list);
    }

    @Override
    public MESResult selectId(Long recordId) {
        TemplateProduct templateProduct=null;
        if ((templateProduct=templateProductMapper.selectByTemplateProductId(recordId))!=null){
            return  MESResult.ok(templateProduct);
        }
        return MESResult.empty();
    }

    @Override
    public MESResult save(TemplateProduct templateProduct) {

        templateProductMapper.save(templateProduct);
        return MESResult.ok();
    }

    @Override
    public MESResult update(TemplateProduct templateProduct) {
        templateProductMapper.update(templateProduct);
        return MESResult.ok();
    }

    @Override
    public MESResult deleteByTemplateProductId(Long recordId) {
        templateProductMapper.deleteByTemplateProductId(recordId);
        return MESResult.ok();
    }

    @Override
    public MESResult deletesByTemplateProductId(Long[] recordId) {
        int count= templateProductMapper.deletesByTemplateProductId(recordId);
        return MESResult.ok(count+"");
    }
}
